package com.xing.controller;

import com.xing.Utils.Result;
import com.xing.entity.LiveApplyEntity;
import com.xing.service.LiveApplyService;
import com.xing.utils.PageData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@Tag(name = "主播申请服务")
@RestController
@RequestMapping(value = "/apply")
public class LiveApplyController {

    @Autowired
    private LiveApplyService applyService;


    @Operation(summary = "分页获取申请信息")
    @GetMapping(value = "/pageApply")
    @PreAuthorize("hasAnyAuthority('admin')")
    public Result pageApply(@RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        PageData<LiveApplyEntity> liveApplyPageData = applyService.pageApply(pageNum,pageSize);
        return new Result().ok(liveApplyPageData);
    }


    @Operation(summary = "处理申请信息")
    @PutMapping(value = "/handleApply")
    @PreAuthorize("hasAnyAuthority('admin')")
    public Result handleApply(@RequestBody LiveApplyEntity liveApplyEntity) {
        return applyService.handleApply(liveApplyEntity);
    }

}
